Fix: Ensure Real-Time Data Retrieval in RootChain Methods (Checkpoint delays) #445
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Overview
This PR addresses an issue with the
getLastChildBlockmethod in theRootChainclass where the data retrieved was 17 minutes old. The change ensures that the data is retrieved in real-time.Changes
Replaced the direct call to
method.readwiththis.processReadin thegetLastChildBlockmethod to ensure real-time data retrieval.Motivation
The previous implementation was returning outdated data, which could lead to inconsistencies and incorrect information being processed. This change ensures that the most up-to-date data is used.
Differences:
Direct Method Call vs. Process Method:
readmethod on themethodobject, passing in an empty object and a default block value.this.processReadwith themethodobject as an argument.Handling of Default Block:
this.client.config.rootChainDefaultBlock || 'safe'.processReadmethod. However, for thegetLastChildBlockmethod, a default block is not needed because it specifically retrieves the latest block. Passing a block would result in retrieving an older block.Timing of Data Retrieval:
processRead, might be fetching the latest data in real-time, depending on howprocessReadis implemented.Conclusion:
The real difference is that
processReaddoes not require a default block, allowing it to fetch the latest block directly. This ensures that the data retrieved is up-to-date, whereas the direct call tomethod.readmight be fetching data from a specific block that is not current. Additionally,processReadprovides additional processing and validation, ensuring that transaction options are valid and properly handled. By usingprocessRead, we leverage existing functionality that is already used in other parts of the code, ensuring consistency and reliability. AlthoughprocessReadultimately callsmethod.read, it does so after performing necessary checks and configurations, making it a more robust and reliable approach.